<template>
  <div class="header-content">
    <div class="header-left">
      <div class="header-logo" @click="$router.push('/')">
        <img src="../assets/logo.png" alt="" />
      </div>
      <div class="header-context">
        <div>加盟咨询</div>
        <div>抖音直播</div>
      </div>
      <div class="header-phone">16684731166</div>
    </div>
    <div class="header-right">
      <div class="header-address">
        <img src="../assets/dw .png" alt="" />
        <div>贵阳</div>
        <img src="../assets/箭头 .png" alt="" />
      </div>
      <div>
        <el-popover placement="bottom" width="320" trigger="click">
          <div class="popup-box">
            <div class="popup-tags">
              <div
                :class="loginType == 1 ? 'isSelected' : ''"
                @click="selectLogin(1)"
              >
                抖音登录
              </div>
              <div
                :class="loginType == 2 ? 'isSelected' : ''"
                @click="selectLogin(2)"
              >
                微信登录
              </div>
            </div>
            <div class="popup-body">
              <div class="body-code">
                <img src="../assets/code.png" alt="" />
              </div>
              <div class="body-text">
                请使用
                <span>{{ loginType == 1 ? "抖音APP" : "微信APP" }}</span>
                扫描二维码登录
              </div>
            </div>
          </div>
          <el-button
            size="medium"
            slot="reference"
            v-if="loginStatus == 0"
            round
            >登录</el-button
          >
        </el-popover>
        <el-popover placement="bottom" width="240" trigger="click">
          <div class="popup-box">
            <div class="user-info">
              <div>
                <el-avatar size="large" :src="circleUrl"></el-avatar>
              </div>
              <div class="info-context">
                <div class="user-phone">13639368864</div>
                <div class="user-identity">
                  <div>ID(668866)</div>
                  <img src="../assets/过客.png" alt="" />
                </div>
              </div>
            </div>
            <div class="menu-list">
              <div
                class="menu-item"
                v-for="(item, index) in menuList"
                :key="index"
                @click="gotoNext(item.url)"
              >
                <div class="menu-title">
                  <img :src="item.img" alt="" />
                  <div>{{ item.title }}</div>
                </div>
                <img src="../assets/矩形 16.png" alt="" />
              </div>
            </div>
          </div>
          <el-avatar
            slot="reference"
            size="large"
            :src="circleUrl"
            v-if="loginStatus == 1"
          ></el-avatar>
          <!-- <el-button size="medium" slot="reference" v-if="loginStatus == 1" round>登录</el-button> -->
        </el-popover>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menuList: [
        {
          img: require("@/assets/zhxx.png"),
          title: "账户信息",
          url: "/AccountInfo",
        },
        {
          img: require("../assets/图层 16.png"),
          title: "我的订单",
          url: "",
        },
        {
          img: require("../assets/ygsp.png"),
          title: "已购视频",
          url: "",
        },
        {
          img: require("../assets/kscj.png"),
          title: "考试成绩",
          url: "/ExamScores",
        },
        {
          img: require("../assets/wdsc.png"),
          title: "我的收藏",
          url: "",
        },
        {
          img: require("../assets/zhxx.png"),
          title: "关于我们",
          url: "/AboutUs",
        },
        {
          img: require("../assets/图层 19.png"),
          title: "注销账号",
          url: "",
        },
      ],
      loginType: 1,
      loginStatus: 1,
      circleUrl:
        "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
    };
  },
  methods: {
    selectLogin(type) {
      this.loginType = type;
    },
    gotoNext(url){
      this.$router.push(url)
    }
  },
};
</script>

<style lang="scss">
.el-popover {
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
}
.el-button {
  padding: 1vh 1.5vw !important;
  color: #2ac092;
}

.el-button:focus,
.el-button:hover,
.el-button:active {
  color: #fff;
  border-color: #2ac092;
  background-color: #2ac092;
}

.header-content {
  padding: 20px 12.5%;
  display: flex;
  justify-content: space-between;
  background-color: #2ac092;

  .header-left {
    display: flex;
    align-items: center;

    .header-logo {
      cursor: pointer;
      width: 30vw;
      height: 6.5vh;
      margin-right: 18px;

      > img {
        width: 100%;
        height: 100%;
      }
    }

    .header-context {
      color: #fff;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      height: 100%;
      font-size: 1vw;
      margin-right: 1vw;

      > div {
        cursor: pointer;
      }
    }

    .header-phone {
      color: #fff;
      font-size: 1.5vw;
    }
  }
  .header-right {
    display: flex;
    align-items: center;

    .header-address {
      display: flex;
      color: #fff;
      margin-right: 0.5vw;
      font-size: 0.9vw;
      cursor: pointer;

      > img {
        width: 1.1vw;
        height: 2.3vh;
      }

      > div {
        margin: 0 0.25vw;
      }
    }
  }
}

.popup-tags {
  display: flex;
  color: #999999;
  background: #f5f5f6;

  > div {
    padding: 1.2vh 0;
    width: 50%;
    text-align: center;
    font-size: 1vw;
    cursor: pointer;
  }
}

.popup-body {
  padding: 3vh 2vw 3vh 2vw;
  display: flex;
  flex-direction: column;
  align-items: center;

  .body-code {
    width: 12vw;
    height: 22vh;
    margin-bottom: 2vh;

    > img {
      width: 100%;
      height: 100%;
    }
  }

  .body-text {
    font-size: 0.8vw;

    > span {
      color: #2ac092;
    }
  }
}

.isSelected {
  background: #fff;
  color: #2ac092;
  width: 100%;
  height: 100%;
}

.user-info {
  display: flex;
  background: #e6f5f0;
  align-items: center;
  padding: 25px 20px;

  .info-context {
    margin-left: 10px;
    font-size: 16px;
    color: #333;

    .user-identity {
      margin-top: 10px;
      display: flex;
    }
  }
}

.menu-list {
  .menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    font-size: 16px;
    cursor: pointer;

    .menu-title {
      display: flex;

      > img {
        margin-right: 20px;
      }
    }
  }
  .menu-item:hover{
    background-color: #e6f5f0;
    color: #333;
  }
}
</style>